﻿using DX.ViewModels;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace DX
{
    public partial class UserControlForm : ViewForm
    {

        public UserControlForm(ViewControl viewControl)
        {
            this.viewControl = viewControl;
            ViewModelBindingSource = viewControl.ViewModelBindingSource;
            Size = viewControl.Size + new Size(10, 50);
            MaximizeBox = false;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            Controls.Add(viewControl);
            DataBindings.Add(new Binding(nameof(Text), ViewModelBindingSource, nameof(IHaveDisplayName.Title), true));

        }
        private readonly ViewControl viewControl;
        public ViewControl GetViewControl() => viewControl;

        public void RemoveViewControl()
        {
            Controls.Remove(viewControl);
        }

        public UserControlForm NewForm()
        {
            RemoveViewControl();
            return new UserControlForm(viewControl);
        }

      
    }
}
